import { Component } from 'react';

import '../../../src/index.css'

class search extends Component {

  state = { 
    text:'', //搜索框
   }

  // 搜索框 
   sou = (e)=>{
    // console.log(e.target.value);
    this.setState({
      text: e.target.value
    })
   } 

  //  点击百度一下获取到搜索框的数据
  bidu = (e)=>{
    // console.log(e);
    this.props.sousuo(this.state.text)
    // this.setState({ //搜索到数据之后把文本框清空
    //   text:""
    // })
  }

  render() { 
    return (
      <>
        <div className='input'>
            <input className='input2' type="text" value={this.state.text} onChange={this.sou} />
            <div className='button' onClick={()=>this.bidu(this.state.text)}>百度一下</div>
        </div>
      </>
     );
  }
}
 
export default search;